package mysql

import (
	"frame/global/consts"
	"frame/global/variable"
	"gorm.io/gorm"
)

type BaseModel struct {
	*gorm.DB `gorm:"-" json:"-"`
}

// PaginationResponse 用于封装分页信息和数据
type PaginationResponse struct {
	Items    interface{} `json:"items"`
	PageInfo PageInfo    `json:"pageInfo"`
}

type PageInfo struct {
	CurrentPage int   `json:"currentPage"`
	PerPage     int   `json:"perPage"`
	Total       int64 `json:"total"`
	TotalPage   int64 `json:"totalPage"`
}

var (
	VIDEO = "video"
	IMAGE = "image"
)

func UseDbConn() *gorm.DB {
	var db *gorm.DB

	if variable.GormDbMysql == nil {
		variable.ZapLog.Error(consts.ErrorsGormNotInitGlobalPointer)
	}
	db = variable.GormDbMysql
	return db
}
